import React, { Component } from 'react'
import {
    NavBar,
    Form,
    Input,
    Button,
    Dialog
 } from 'antd-mobile'
 import {Navigate} from 'react-router-dom'
import SelectPhoto from '../../components/SelectPhoto/'
import  {reqUpadate} from '../../api/'

export default class SeekerInfo extends Component {
    state={
        isSave:false
    }
    header=''
    save=async()=>{
       
        try{
            const values = await this.form.validateFields();
            console.log(values)
            if(!this.header){
                Dialog.alert({
                    content:'请选择头像'
                })
                return 
            }
            values.header=this.header
            const response= await reqUpadate(values)
            if(!response.data.code){
                //重新跳转
                this.setState({isSave:true})
            }else{

            }
        }catch(error){
            console.log(error)
        }
       
    }
    setRef=(form)=>{
        this.form=form
    }
    setHeader=(header)=>{
        this.header=header
    }
    render() {
        return (
            <div>
                 {this.state.isSave?<Navigate to='/main/dashen'/>:''}
                 <NavBar backArrow={false}  className="navbar">大神完善信息页</NavBar>
                 <SelectPhoto setHeader={this.setHeader}></SelectPhoto>

                 <Form layout="horizontal" ref={this.setRef}>
                     <Form.Item name="post" label="求职岗位：">
                         <Input placeholder="请输入求职岗位"></Input>
                     </Form.Item>
                     <Form.Item name="info" label="个人介绍:">
                         <Input  placeholder="请输入个人介绍"></Input>
                     </Form.Item>
                 </Form>
                 <Button color="primary" block onClick={this.save}>保存</Button>
            </div>
        ) 
    }
}
